// eventBus.js  
import {
	reactive
} from 'vue';
const EventBus = reactive({
	on(event, callback) {
		this._events = this._events || {};
		(this._events[event] = this._events[event] || []).push(callback);
	},
	off(event, callback) {
		const events = this._events && this._events[event];
		if (events) {
			this._events[event] = events.filter(cb => cb !== callback);
		}
	},
	emit(event, ...args) {
		const events = this._events && this._events[event];
		if (events) {
			events.forEach(cb => cb(...args));
		}
	}
});

export default EventBus;